let app = getApp()
Component({
    properties: {
 
      },
      data:{
        currentData: 0,
        orderby:'desc',
        defaults: {
            by: "desc"
        },
        class_list: [ {
            id: "0",
            name: "全部"
        } ],
        show: !1,
        topRefresh: 0,
        bottomRefresh: 0,
        item: {
            class_ids: 0,
            data_type: "auto",
            id: "services-list-1",
            num: 10,
            order: "id",
            showtitle: !0,
            sort: "desc",
            css: {},
            animation: {},
            list: []
        },
        page_path: "pages/services/list/index",
        class_id: 0,
      },
    lifetimes: {
        attached: function () {
           this.setData({
             globalColor:app.globalData.globalColor
           })
           this.get_data()
       }
      },
    methods: {
      list_Data:function(num,class_ids,sort,order,data_type,page){
        var item={
          class_ids: 0,
          data_type: "auto",
          id: "services-list-1",
          num: num,
          order: order,
          showtitle: !0,
          sort:sort,
          css: {},
          animation: {},
          list: []
        }
        this.setData({
          item:item
        })
        var that=this
        wx.request({
          url: app.globalData.siteroot,
          data: {
            do:'List_Data',
            type:'services',
            num:num,
            class_ids:class_ids,
            sort:sort,
            order:order,
            ids:'',
            data_type:data_type,
            page:page,
            user_id:wx.getStorageSync('user_id'),
          },
          success: function(res) {
            var item=that.data.item
             item.list=res.data.info
             item.type='services'
             that.setData({
              item:item
             })
          }
        })
      },
      get_data:function(){
        var that=this
        wx.request({
          url: app.globalData.siteroot,
          data: {
            do:'Services_getServicesClass',
            staff_id:wx.getStorageSync('staff_bind_id')
          },
          success: function(res) {
           var class_list=that.data.class_list
           class_list=class_list.concat(res.data.info)
             that.setData({
              class_list:class_list
             })
          }
        })
        this.list_Data(that.data.item.num,that.data.item.class_ids,that.data.item.sort,that.data.item.order,that.data.item.data_type,1);
      },
      changeclass:function(e){
        this.setData({
          class_id:e.currentTarget.dataset.class_id
        })
      },
      changecurrent:function(e){
        var that=this
        if(e.currentTarget.dataset.current==3){
          if(this.data.show){
            this.setData({
              show:false
            })
          }else{
            this.setData({
              show:true
            })
          }
        }else if(e.currentTarget.dataset.current==1){
            if(this.data.orderby=='desc'||this.data.orderby=='price-desc'){
              this.setData({
                orderby:'price-asc'
              })
              this.list_Data(that.data.item.num,that.data.item.class_ids,'asc','price',that.data.item.data_type,1);
            }else{
              this.setData({
                orderby:'price-desc'
              })
              this.list_Data(that.data.item.num,that.data.item.class_ids,'desc','price',that.data.item.data_type,1);
            }
        }else{
          this.setData({
            show:false
          })
        }
        this.setData({
          currentData:e.currentTarget.dataset.current
        })
      }
    }
});
